<template>
	<view class="u-padding-top-30">


		<view class="mdx-center-min u-m-t-30 infoBox" v-if="list.length">
			<view class="teamList u-flex" v-for="(item,index) in list" :key='index'>
				<view>
					<u-avatar size="120" mode='square' :src="item.headimgurl"></u-avatar>
				</view>
				<view class="u-margin-left-10 u-flex-1">
					<view class="username">{{item.nickname}}</view>
					<view class="u-flex u-row-between u-m-t-10">
						<view>
							<u-rate :disabled='true' active-icon='xingxing' inactive-icon='xingxing' size="32"
								custom-prefix='custom-icon' active-color='#FFBD12' :count="count" v-model="value">
							</u-rate>
						</view>
						<view class="u-flex">
							<view class="btns block" @click="tiAndjj(item,2,index)">
								拒绝
							</view>
							<view class="btns release" @click="tiAndjj(item,1,index)">
								同意
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<u-toast ref="uToast" />
		<view v-if="list.length<1" style="padding-top: 400rpx;" class="u-p-b-100">
			<u-empty icon-size="280" text="暂无数据~" src="/static/images/noneList.png"></u-empty>
		</view>
		<view class="u-padding-20" v-else>
			<u-loadmore :status="status" />
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				//评分
				count: 5,
				value: 5,

				status: 'loadmore',
				list: [],
				page: 1,
				pageSize: 10,
			}
		},
		onLoad() {
			this.getApplyList(); //获取申请列表
		},
		onReachBottom() {
			if (this.status != 'nomore') {
				this.status = 'loading';
				setTimeout(() => {
					this.getApplyList();
				}, 500);
			}
		},
		onPullDownRefresh() {
			setTimeout(() => {
				this.page = 1;
				this.list = [];
				this.status = 'loadmore';
				this.getApplyList();
			}, 800);
		},
		methods: {
			getApplyList() {
				this.$http.get('api/Tmy/teaminfod', {
					page: this.page,
					limit: this.pageSize,
				}).then(res => {
					if (res.code == 0) {
						res.data.forEach(e => {
							this.list.push(e)
						})
						if (res.data.length < this.pageSize) this.status = 'nomore';
						else this.status = 'loadmore';
					}
					uni.stopPullDownRefresh();
				})
			},
			tiAndjj(item, type, index) {
				let url = ''
				if (type == 1) {
					url = 'api/Tmy/okadd'
				} else {
					url = 'api/Tmy/noadd'
				}
				this.$http.get(url, {
					id: item.id,
					u_star:5
				}).then(res => {
					if (res.code == 0) {
						this.list.splice(index, 1);
						this.$refs.uToast.show({
							title: res.msg,
							type: 'success',
						})
					} else {
						this.$refs.uToast.show({
							title: res.msg,
							type: 'error',
						})
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		background: #FFF;
	}

	.infoBox {
		background: #FFFFFF;
		box-shadow: 0 0 10rpx #dddddd;
		padding: 25rpx 20rpx;

		.username {
			font-size: 32rpx;
			font-weight: 550;
		}

		.teamname {
			font-size: 26rpx;
			color: #999;
			margin-top: 25rpx;
		}
	}

	.actTitless {
		font-size: 32rpx;
		font-weight: 550;

	}

	.teamList {
		margin-bottom: 30rpx;

		.username {
			font-size: 32rpx;
			font-weight: 550;
		}

		.teamname {
			font-size: 26rpx;
			color: #999;
			margin-top: 25rpx;
		}
	}

	.btns {
		padding: 7rpx 16rpx;
	}

	.block {
		color: #999999;
		border: 1rpx solid #999999;
		border-radius: 10rpx;
	}

	.release {
		background-color: #FFEC3E;
		color: #666666;
		margin-left: 20rpx;
	}
</style>
